package com.example.back.controller;

import com.example.back.dto.req.DeleteEscortTypeDto;
import com.example.back.dto.resp.EscortTypeList;
import com.example.back.service.EscortTypeService;
import com.example.common.entity.EscortType;
import com.example.common.support.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @ClassName EscortTypeController
 * @Author wengjt
 * @Date 2021/5/7 16:26
 * @Description
 **/
@RestController
@RequestMapping("/escortType")
@Api(tags = "陪护类型管理")
public class EscortTypeController {
    @Resource
    private EscortTypeService escortTypeService;

    @GetMapping("/list")
    @ApiOperation(value = "多条件查询陪护分类列表")
    public Result<EscortTypeList> getEscortTypeList(Long etId, Integer showAble,Integer pageNum,Integer pageSize){
        return Result.success(escortTypeService.getEscortTypeList(etId,showAble,pageNum,pageSize));
    }
    @GetMapping("/info")
    @ApiOperation(value = "返回单个陪护分类详情")
    public Result<EscortType> getEscortType(Long etId){
        return  Result.success(escortTypeService.getEscortType(etId));
    }
    @PutMapping("")
    @ApiOperation(value = "修改陪护分类")
    public Result<Object> updateByEtId(@RequestBody EscortType escortType){
        return Result.success(escortTypeService.updateByEtId(escortType));
    }
    @PostMapping("")
    @ApiOperation(value = "新增陪护分类")
    public Result<Object> insertOne(@RequestBody EscortType escortType){
        return Result.success(escortTypeService.insertOne(escortType));
    }
    @DeleteMapping("")
    @ApiOperation(value = "删除陪护类型")
    public Result<Object> deleteOne(DeleteEscortTypeDto dto){
        return Result.success(escortTypeService.deleteOne(dto.getEtId()));
    }
}
